package com.crl.rcdp.auth.controller;

import com.cars.util.json.JsonResult;
import com.crl.rcdp.sys.dto.SysAppLoginDTO;
import com.crl.rcdp.sys.service.SysAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description:通过appsecrect的校验方式
 * @author: 孔垂云
 * @version: 1.0
 * @date: 2020/7/26 23:50
 */
@RestController
@RequestMapping("/auth/app")
public class AuthAppsecrectController {
    @Autowired
    private SysAppService sysAppService;

    //1、获取token；2、刷新token
    @RequestMapping("/createToken")
    public JsonResult createToken(@RequestBody SysAppLoginDTO sysAppLoginDTO) {
        return sysAppService.createAccessToken(sysAppLoginDTO);
    }

    /**
     * 刷新token
     *
     * @return
     */
    @RequestMapping("/refreshToken")
    public JsonResult refreshToken(@RequestBody Map<String, String> map) {
        return sysAppService.refreshToken(map.get("refreshToken"));
    }


}
